package com.lin.entity.key;

import lombok.Data;

import java.util.Objects;

/**
 * websocket主题
 */
@Data
public class WsTopicKey {
    private String topic;

    private Long userId;

    public WsTopicKey(String topic, Long userId) {
        this.topic = topic;
        this.userId = userId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        WsTopicKey that = (WsTopicKey) o;
        if(userId == null) return topic.equals(that.topic);
        return topic.equals(that.topic) && userId.equals(that.userId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(topic, userId);
    }
}
